﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="EditBOM.aspx.cs" Inherits="Main_Inventory_EditBOM" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="AjaxControl" %>
<%@ Register Src="~/User Controls/PageHeading.ascx" TagName="heading" TagPrefix="acc" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>BOM Edit</title>
    <link rel="Stylesheet" href="../../Styles/accounts.css" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <asp:ScriptManager ID="ScriptManager1" EnablePartialRendering="true" EnablePageMethods="true" runat="server"> </asp:ScriptManager>
        <div class="divmain" > <acc:heading ID="pagehead" runat="server" HeadingText="BOM Edit" /> </div>    
            <div style="width:90%; margin-left:5%; margin-right:5%;">        
                
                <%--<asp:UpdatePanel ID="UpdatePanel1" runat="server">
                    <ContentTemplate>
                --%>        
                        <div style="margin-left:5%; margin-right:5%; width:90%" align="center"><asp:Label ID="lblMsg" runat="server" Font-Bold="true"></asp:Label></div> 
                            
                            <asp:UpdateProgress DynamicLayout="false" ID="UpdProgress" runat="server">
                                <ProgressTemplate> <div align="center"><img src="../../Images/ajax-loader.gif" /></div> </ProgressTemplate>
                            </asp:UpdateProgress>
                                  
                                  <asp:HiddenField ID="HidControl" runat="server" Value="5" /> 
                                
                                    <table class="tablecontent"  style= "width:85%; margin-left:5%; border:1px solid #818181" >
                                          <tr>
                                                <td class="headtd" colspan="6"> 
                                                   Items Details
                                                   
                                               </td>
                                               
                                          </tr>
                                         
                                         <tr>
                                                <td  style="width:40%">Item <span style="color:Red">*</span>&nbsp; </td>
                                                <td colspan="5" style="width:60%">
                                                    <asp:Label ID="LblItemName" runat="server"></asp:Label>
                                                    <asp:HiddenField ID="HidItemId" runat="server" />
                                                </td>
                                         </tr>
                                         
                                         <tr>
                                                <td style="width:20%">Quantity <span style="color:Red">*</span>&nbsp;  </td>
                                                <td style="width:20%"> <asp:TextBox ID="TxtQuantity" runat="server" Text="0.00" CssClass ="inputnumber" onKeyPress= "return isNumberKey(this.id,event)" onKeyUp="GetTextBoxValue(this.id)" onBlur="SetZero(this.id)" > </asp:TextBox> </td>
                                                <td style="width:20%"> Unit Symbol</td>
                                                <td style="width:20%"> <asp:TextBox ID="TxtUnitSymbol" ReadOnly="true" CssClass="input" runat="server"> </asp:TextBox></td>
                                                <td style="width:10%">Active </td>
                                                <td style="width:10%"> <asp:CheckBox ID="ChkActive" runat="server" /></td>
                                         </tr>
                                         
                                          <tr>
                                                <td> Remarks </td>
                                                <td colspan="5"> <asp:TextBox ID="TxtRemarks" TextMode="MultiLine" Width="140px" MaxLength="100" runat="server"> </asp:TextBox> </td> 
                                         </tr>
                                         
                                         <tr>
                                                <td> Edit in Transaction</td>
                                                <td colspan="5"> <asp:CheckBox ID="ChkEditTransaction" runat="server" /></td>
                                         </tr>
                                         
                                   </table>
                               
                                        <table id="tblItem" runat="server" style="width:85%; margin-left:5%; margin-top:10px;" class="tablecontent" cellpadding="2" cellspacing="0">
                                            <tr>
                                                <td style ="border-right:1px solid #818181; border-bottom:1px solid #818181; text-align:center; font-weight:bold">Item Name</td>
                                                <td style ="border-right:1px solid #818181; border-bottom:1px solid #818181; text-align:center; font-weight:bold">Unit</td>
                                                <td style ="border-right:1px solid #818181; border-bottom:1px solid #818181; text-align:center; font-weight:bold">Quantity</td>
                                            </tr>
                                        
                                        </table>
                                        
                                        
                                  <table style="width: 95%; margin-top: 10px;" align="right">
                                            <tr>
                                                <td >
                                                    <asp:LinkButton ID="btnAddMore" runat="server" OnClick="btnAddMore_Click"
                                                       CausesValidation="false" > 
                                                        <img src="../../Images/More.jpg" alt="Add New Row" />
                                                    </asp:LinkButton>
                                                </td>
                                            </tr>
                                 </table>
                                
                                <table style="width:85%; margin-left:5%; margin-top:5%">
                                        <tr>
                                            <td style="width:19%;" align="right" >  
                                                    <asp:Button ID="BtnSave" runat="server" CssClass="button" Text="Save"   
                                                        OnClientClick="return ValidateItems();" onclick="BtnSave_Click" />
                                                    
                                            </td>
                                            <td style="width:14%;" align="left" >&nbsp; <asp:Button ID="BtnClose" 
                                                    runat="server" CssClass="button" Text="Close" onclick="BtnClose_Click" /> </td>
                                            <td style="width:8%;"> &nbsp;</td>
                                        </tr>
                                </table>
                                
                     
                                
                                
                      <%--  </ContentTemplate>
                     </asp:UpdatePanel>--%>
                  </div>
    </div>
    </form>
    <script language="javascript" type="text/javascript">
        function checkItemRepetion(id) {
            //function to prevent duplicate item selection
            var flag = new Boolean(true);
            var ddl = document.getElementById(id);
            var currentValue = ddl.options[ddl.selectedIndex].value;
            var Count = document.getElementById("HidControl").value;
            for (var i = 1; i <= Count; i++) {
                var previous = document.getElementById("DDLItemName" + i);
                var previousValue = previous.options[previous.selectedIndex].value;
                if (ddl.value == '0') {
                    document.getElementById("TxtUnit" + i).value = '';
                    flag = false;
                }
                else if (ddl != previous) {
                    if (currentValue == previousValue) {
                        alert('Please Select Unique Item');
                        ddl.selectedIndex = 0;
                        flag = false;
                        break;
                    }
                }
            }
            if (flag == true) {                                       //use only when your
                setTimeout('__doPostBack(\'' + id + '\',\'\')', 0);       // dropdown has autopostback as true.
            }                                                             // otherwise leave this line commented.
            return flag;
        }
        function validatecontrols() {
            var count = document.getElementById("HidControl").value;
            var isvalid = new Boolean(true);

            for (var i = 1; i <= count; i++) {
                if (document.getElementById("DDLItemName" + i).selectedIndex != '0') {
                    if (document.getElementById("TxtQty" + i).value == '' || parseFloat(document.getElementById("TxtQty" + i).value) == 0) {

                        isvalid = false;
                        break;

                    }
                }
            }
            return isvalid;
        }
        function ValidateItems() {

            //var flag=new Boolean(true);
           
            if (document.getElementById("DDLItemName1").selectedIndex == '0') {
                alert('Please Select First Item ');
                document.getElementById("DDLItemName1").focus();
                return false;

            }
            else if (document.getElementById("TxtQty1").value == '' || parseFloat(document.getElementById("TxtQty1").value) == 0) {
                alert('Please Enter Valid Quantity');
                document.getElementById("TxtQty1").focus();
                return false;
            }
            else if (!validatecontrols()) {
                alert('Please Enter Valid Quantity');
                return false;
            }
            else {
                return true;
            }

        }
    </script>
    <script src="../../JavaScript/Commons.js" type="text/javascript"></script>
</body>
</html>
